package testJdk.commonUse.string;

import org.junit.Test;

/**
 * @version 1.0.0
 * Created by cyd on 2023-07-07 18:33:54
 * @ClassName : testJdk.commonUse.string.TestFindStr
 * @Description : 类描述
 */
public class TestFindStr {

    /**
     * 使用startWith，endWith，contain来配置字符串
     */
    @Test
    public void test01() {
        String str = "java,java,hello world";
        String[] split = str.split(",");
        for (String s : split) {
            if (s.startsWith("j")) System.out.println(s);
        }
        System.out.println("-------------------");
        for (String s : split) {
            if (s.endsWith("d")) System.out.println(s);
        }
        System.out.println("-------------------");
        for (String s : split) {
            if (s.contains("v")) System.out.println(s);
        }
    }

    /**
     * 通过chatAt来定位
     */
    @Test
    public void test02() {
        String str = "java,java,hello world";
        String substring = str.substring(0, 4);
        if (substring.equals("java")) {
            System.out.println(str);
        }
    }
}
